<div id="content">
	<div id="top">
		<h3>Add New</h3>
		<%= render :partial => '/partials/help_link', :locals => {:path => {:controller => "help", :action => "items", :anchor => "new"}} %>
	</div>
    <% @source_id = @current_user.location_id %>
    <% @client_id = @current_user.id %>
	<% @attribute_sets = ItemAttributeSet.all %>
	<% @other_attributes = ItemAttribute.find_all_by_item_attribute_set_id(nil) %>
	<%= error_messages_for :item %>
	<% form_for @item do |f| %>
		<%= render :partial => '/partials/create_form', :locals => {:f => f} %>
		<% @types = ItemType.find_all_by_hidden(:false) %>
		<% @visibility_div = "contained_items_visibility" %>
		<% @container_div = "contained_items" %>
		<% @js_function = "TypeOnChange" %>
		<div class="edit">
			<% @contained_types = ItemType.find_all_by_hidden_and_is_container(:false, :false) %>
			<%= render :partial => 'item_form', :locals => {:f => f} %>
			<div class="edit-table">
				<div id="<%= @visibility_div %>" style="display:<%= (@item.item_type && @item.item_type.is_container) ? "" : "none" %>">
					<div class="edit-row">
						<div class="left">
							<h3>Items in Container</h3>
						</div>
						<div class="right">
							<div id="<%= @container_div %>">
								<%= render :partial => "contained_item_form", :collection => @item.contained_items, :locals => {:prefix => "item[contained_item_attributes]"} %>
							</div>
							<%= add_contained_item("Add new Item to Container", @container_div, "item[contained_item_attributes]") %>
						</div>
					</div>
				</div>
			</div>
		</div>
		<%= render :partial => '/partials/create_form', :locals => {:f => f} %>
	<% end %>
</div>
<script type="text/javascript">

  $('new_item').observe('keydown', function(e) {
    if (e.keyCode == 13) {
      e.returnValue = false;
    }
  });

</script>